import { CoolController, BaseController } from '@cool-midway/core';
import { Body, Inject, Post, Get, Query } from '@midwayjs/core';
import { HelperUserInfoEntity } from '../../entity/info'; 
import { HelperUserInfoService } from '../../service/info'; 

/**
 * helper模块-用户信息
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: HelperUserInfoEntity,
  service: HelperUserInfoService,
  pageQueryOp: {
    keyWordLikeFields: ['name', 'remark', 'url', 'icon', 'themeColor', 'bgColor', 'tab', 'imputeTo', 'reportCycle'],
    fieldEq: ['isZip', 'screenOrientation', 'fullScreen', 'needPreload', 'firstActionReport', 'status', 'hide'],
    where: async (ctx) => {
      return [
        ['a.userId = :userId', { userId: ctx.query.userId }],
      ]
    },
  }
})
export class AdminHelperUserInfoController extends BaseController {
    @Inject()
    helperUserInfoService: HelperUserInfoService;

    @Post('/detail', { summary: '获取用户信息详情' })
    async detail(@Body('id') id: number) {
        return this.ok(await this.helperUserInfoService.info(id));
    }
}
